﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameLib {
    public class Deck<T> : List<T> {
        private MersenneTwister.RandomizeMT alea = new MersenneTwister.RandomizeMT((ulong)DateTime.Now.Ticks);

        /// <summary>
        /// Mélanger le deck
        /// </summary>
        public void Shuffle() {
            for (int k = 0; k < this.Count; k++) {
                for (int i = this.Count - 1; i > 0; i--) {
                    int j = alea.RandomRange(0, this.Count - 1);
                    T tmp = this[i];
                    this[i] = this[j];
                    this[j] = tmp;
                }
            }
        }

        /// <summary>
        /// Retourner le premier élément de la pile
        /// </summary>
        public T Dequeue() {
            T item = this.ElementAt(0);
            this.RemoveAt(0);
            return item;
        }

        /// <summary>
        /// Ajouter un élément dans la pile
        /// </summary>
        public void Enqueue(T item){
            this.Add(item);
        }
    }
}
